import request from "@/utils/request";

/**
 * ...获取属性列表的所有类型
 */
export interface attrValueItemType {
  id?: number; //自己的id
  valueName?: string; // 属性值名字
  attrId?: number; // 属于谁的id
  isShow?: boolean;
}

export type attrValueListType = attrValueItemType[];

export interface attrItemType {
  id?: number;
  attrName: string;
  categoryId: number | null;
  categoryLevel: number;
  attrValueList: attrValueListType;
  attrIdValueId?: string;
}
export type attrListType = attrItemType[];
/**
 * 请求获取平台属性列表
 * @param category1Id
 * @param category2Id
 * @param category3Id
 * @returns
 */
export const reqGetAttrInfo = (
  category1Id: number,
  category2Id: number,
  category3Id: number
) => {
  return request.get<null, attrListType>(
    `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`
  );
};
/**
 * 请求添加平台属性
 * @param attrValueInfo
 * @returns
 */
export const reqAddAttrInfo = (attrValueInfo: attrValueItemType) => {
  return request.post<null, null>(`/admin/product/saveAttrInfo`, attrValueInfo);
};
/**
 * 请求删除平台属性
 * @param attrId
 * @returns
 */
export const reqDelAttrInfo = (attrId: number) => {
  return request.delete<null, null>(`/admin/product/deleteAttr/${attrId}`);
};
